package demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-08-24
 * Time:16:56
 */
//继承
//final关键字

/*class Dog extends Animal{   //编译出错，父类被final修饰（密封类），无法被继承
    public void bark(){
        System.out.println(this.name + "正在汪汪叫...");
    }
}*/

//修饰类：表示此类不能被继承
final public class Animal {
    public String name;
    public int age;

    public void eat(){
        System.out.println(this.name + "正在吃饭...");
    }

    public static void main(String[] args) {
        //修饰变量或字段，表示常量(即不能修改)
        final int a = 100;
        //a = 200;//编译出错
    }
}





